<?php 

/*
 *This helper provide access to user parameters such as username, id, etc., of currently logged in user
 *Send comments and feature request to ragrawal at gmail dot com
 *@author - Ritesh Agrawal
 *@version 0.1.0 
 *@license MIT
 */
class AuthHelper extends Helper {
	var $helpers = array ('Session');

	/***
	 * Check whether a user is logged in or not
	 */
	function sessionValid(){
		return ($this->Session->check('Auth.User'));
	}

	/*
	 * Retrieve user information
	 *@param string $key - user table field such as username, id, etc.
	 *@return  if valid then then value otherwise false;
	 */
	function user($key) {
		// does session exists
		if ($this->sessionValid()) {
			$user = $this->Session->read('Auth.User');
			if (isset($user[$key])) {
				return $user[$key];
			}
		}
		return false;
	}

}
?>